﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Reflection;

namespace JackyCode.Mock.Test
{
    [TestFixture]
    public class TestMock
    {
        [Test]
        public void TestObjectProperty()
        {
            Mock<IService> mockInterface = new Mock<IService>(new FakeMockObjectFactory());
            Assert.IsTrue(mockInterface.Object is IService);

            Mock<IService> nonArgsMockInterface = new Mock<IService>();
            Assert.IsTrue(nonArgsMockInterface.Object is IService);

            Mock<Service> nonArgsMockClass = new Mock<Service>();
            Assert.IsTrue(nonArgsMockClass.Object is Service);
        }

        [Test]
        [ExpectedException(ExpectedException = typeof(ArgumentNullException))]
        public void TestInitializeMockWithNullValue()
        {
            Mock<IService> mockInterface = new Mock<IService>(null);
        }

        [Test]
        public void TestSetUp()
        {
            Mock<IService> mock = new Mock<IService>();
            ISetUp<string> isu =  mock.SetUp(service => service.HelloWorld());
            
            MethodInfo methodInfo = 
                typeof(IService).GetMethod("HelloWorld",BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);

            Assert.AreEqual(methodInfo, isu.GetMethodInfo());
        }
    }
}
